package com.feng.study.demo;

import com.feng.study.value.User;
import com.google.common.collect.Lists;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author: Zeng ShaoYong
 * @Date: 2021-11-06
 * @Description:
 */
public class StreamMap {
    public static void main(String[] args) {
        User user = new User();
        user.setName("zhang").setAge(11);

        User user1 = new User();
        user1.setName("zhang").setAge(22);
        List<User> list= Lists.newArrayList(user,user1);
        Map<String, User> collect = list.stream().collect(Collectors.toMap(User::getName, Function.identity()));
        System.out.println(collect);
    }
}
